package com.campus.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.campus.mapper.ClassMapper;
import com.campus.pojo.po.ClassInfo;
import com.campus.pojo.vo.ClassVO;
import com.campus.service.ClassService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class ClassServiceImpl implements ClassService {

    private final ClassMapper classMapper;

    /**
     * 通过专业id获取班级信息
     * @param id 专业id
     * @return 班级列表
     */
    @Override
    public List<ClassVO> getClassByMajorId(Integer id) {
        List<ClassInfo> classInfo = classMapper.getClassByMajorId(id);
        return BeanUtil.copyToList(classInfo, ClassVO.class);
    }
}
